package com.malty.apimanage.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.malty.apimanage.domain.dto.user.api.UserApiStatistic;
import com.malty.common.domain.entity.UserApiInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Administrator
 * @description 针对表【user_api_info】的数据库操作Mapper
 * @createDate 2025-09-29 15:52:00
 * @Entity com.malty.apimanage.domain.UserApiInfo
 */
@Mapper
public interface UserApiInfoMapper extends BaseMapper<UserApiInfo> {

    /**
     *
     */
    @Select("SELECT  a.api_name, a.url, u.api_id, sum(u.used_calls) as used_calls  FROM user_api_info AS u " +
            "INNER JOIN api_meta_data AS a ON u.api_id= a.id GROUP BY u.api_id ORDER BY sum(used_calls) DESC ")
    List<UserApiStatistic> listApiStatistics();
}




